import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Jun Xu
 * Date：2024/1/15
 * Time: 15:07
 */
public class java_1_15_b {
    //求 N 的阶乘
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入n: ");
        int n = sc.nextInt();
        System.out.println("n的阶乘为:"+N_factorial(n));
    }
    private static int N_factorial(int n){
        int sum = 1;
        while(n > 1){
            sum *= n;
            n--;
        }
        return sum;

    }
    //在同一个类中定义多个方法：要求不仅可以求2个整数的最大值，还可以求3个小数的最大值？
    /*public static void main(String[] args) {
        int a = 1;
        int b = 2;
        double c = 1.0;
        double d = 2.0;
        double e = 3.0;
        System.out.println("最大值为: "+maxNumber(a, b));
        System.out.println("最大值为:"+maxNumber(c, d, e));

    }
    private static int maxNumber(int a,int b){
        if(a > b){
            return a;
        }else {
            return b;
        }
    }
    private static double maxNumber(double c,double d,double e){
        if(c > d && c > e){
            return c;
        }else if(d > c && d > e) {
            return d;
        }else if(e > c && e > d){
            return e;
        }
        return 0;
    }*/


    //有一组数据，只有一个数字是出现一次，其他是两次，请找出这个数字。
    /*public static void main(String[] args) {
        int[] arr = new int[]{1,1,2,3,3,4,4};
        //int ret = find_num(arr);
        //System.out.println(ret);
        int ret = find_num(arr);
        System.out.println(ret);
    }
    public static int find_num(int[] arr){
        int ret = 0;
        //异或运算
        for(int num : arr){
            ret ^= num;
        }
        return ret;*/
        /*while(true){
            boolean flag = false;
            for(int i = 0;i < arr.length;i++){
                for(int j = 0;j < arr.length;j++){
                    if(arr[i] == arr[j] && i!=j){
                        flag = true;
                        break;
                    }
                }
                if(flag == false){
                    System.out.println(i);
                }
                break;
            }
            break;
        }*/
        //return i;
   // }


    //求1！+2！+3！+4！+........+n!的和

    /*public static void main(String[] args) {
        Scanner scanners = new Scanner(System.in);
        System.out.println("请输入n的值: ");
        int n = scanners.nextInt();
        int sum = factorial(n);
        System.out.println(sum);
    }
    public static int factorial(int num){
        int sum = 0;
        //int m = n;
        while(num > 0){
            int n = num;
            for(int i = 1;i < num;i++){
                n *= i;
            }
            sum += n;
            num--;
        }
        return sum;
    }*/



    //在同一个类中,分别定义求两个整数的方法 和 三个小数之和的方法。并执行代码，求出结果
    /*public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入a: ");
        int a = sc.nextInt();
        System.out.println("请输入b: ");
        int b = sc.nextInt();
        System.out.println("请输入c: ");
        int c = sc.nextInt();
        int sum1 = sum(a,b);
        int sum2 = sum(a,b,c);
        System.out.println("a+b= "+ sum1);
        System.out.println("a+b+c= "+ sum2);


    }
    public static int sum(int a,int b,int c){
        int ret = a + b + c;
        return ret;
    }
    public static int sum(int a,int b){
        int ret = a + b;
        return ret;
    }*/
}
